const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: '/',
  outputDir: 'vue-seed',
  assetsDir: 'assets',
  // devServer: {
  //   proxy: {
  //     '/api': {
  //       // target: 'http://192.168.3.20:30011', // 线上
  //       target: 'http://116.62.48.48:30011', // 线上
  //       changeOrigin: true,
  //       pathRewrite: {
  //         '^/api': '/'
  //       }
  //     }
  //   }
  // },
  lintOnSave: true, // 'error'
  productionSourceMap: process.env.VUE_APP_CURRENTMODE !== 'production',
  configureWebpack: {
    externals: {
      xlsx: 'XLSX',
      echarts: 'echarts'
    }
    // optimization: {
    //   splitChunks: {
    //     minSize: 10000,
    //     maxSize: 250000
    //   }
    // }
  },
  chainWebpack: config => {
    // 修复HMR
    // config.resolve.symlinks(true);
    config.devServer.set('disableHostCheck', true);
    config.resolve.extensions.add('.vue').add('.scss');
    config.resolve.alias
      .set('@', resolve('src'))
      .set('assets', resolve('src/assets'))
      .set('components', resolve('src/components'))
      .set('views', resolve('src/views'));
  }
};
